package com.kc.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.kc.bean.GroundAccount;
import com.kc.mapper.GroundAccountMapper;
import com.kc.service.IGroundAccountService;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.concurrent.CompletableFuture;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author jobob
 * @since 2019-10-16
 */
@Service
public class GroundAccountServiceImpl extends ServiceImpl<GroundAccountMapper, GroundAccount> implements IGroundAccountService {

    @Resource
    private GroundAccountMapper groundAccountMapper;

    @Override
    public String GetGroudId(String accountId) {
        return groundAccountMapper.GetGroudId(Wrappers.<GroundAccount>lambdaQuery().eq(GroundAccount::getAccountId,accountId));
    }


    /**
     * 此操作为了异步插入，因为表多，选择异步处理
     * 写法是因为资料说同一个类无法进行
     * @param account
     * @return
     */
    @Async
    @Override
    public CompletableFuture<Integer> instGroudAccount(GroundAccount account) {
        int i = groundAccountMapper.insert(account);
        return CompletableFuture.completedFuture(i);
    }
}
